import 'package:flutter/material.dart';

class EnvironmentAssort extends StatefulWidget {

    final List<List> data = [

                    [[{'name':'货运站距离','content':'100KM'},{'name':'港口距离','content':'1000KM'}],
                    [{'name':'高铁距离','content':'100KM'},{'name':'机场距离','content':'1000KM'}],
                    {'name':'区位介绍','content':'根据马斯洛需求理论，人的第一需求是生存需求，在现代文明社会，一个人要生存下去，必须有一份好工作，以后养老有保障。而单位是否给职员买五险一金非常重要，那2019五险一金新政策内容是什么?现在社保基数是多少?一起来看看。 提示：百度搜索“社保网、社会保障网、中国社保、中国社会保障网、中国社保网”，可快速找到本站。五险一金分别指的是什么?'},
                    {'name':'公路运输','content':'是'},{'name':'铁路运输','content':'是'},],

                    [[{'name':'园区周边房价','content':'21312.0元/月'},{'name':'本市住房均价','content':'21312.0元/月'}],
                    [{'name':'两居室租金','content':'21312.0元/月'},],
                    {'name':'园区生活配套','content':'住着可带劲'},
                    {'name':'居住环境','content':'是'},{'name':'商业环境','content':'是'},{'name':'超市','content':'是'},{'name':'百货商场','content':'是'},
                    {'name':'酒店商务','content':'是'},{'name':'休闲娱乐','content':'是'},{'name':'医疗','content':'是'},{'name':'教育','content':'是'}]
                    ];

  @override
  _EnvironmentAssortState createState() => _EnvironmentAssortState();
}

class _EnvironmentAssortState extends State<EnvironmentAssort>
    with SingleTickerProviderStateMixin {

    @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('环境配套'),
      ),
      backgroundColor: Colors.white,
      body: ListView(
        // padding: EdgeInsets.only(top: ),
        physics: ScrollPhysics(),
        children: <Widget>[
          SizedBox(
            height: 16.0,
          ),
          MyItem(widget.data[0]),
          SizedBox(
            height: 10.0,
            child: Container(
              color: Color(0xffebebeb),
            ),
          ),
          SizedBox(
            height: 16.0,
          ),
          MyItem(widget.data[1]),
        
        ],
      ),
    );

  }
}

 class MyItem extends StatelessWidget {

   final List subList;

   MyItem(this.subList);

   @override
   Widget build(BuildContext context) {
     return Container(
       color: Colors.white,
       child: ListView.builder(
       
       physics: NeverScrollableScrollPhysics(),
       shrinkWrap: true,
       itemCount: subList.length,
       itemBuilder: (BuildContext context, int index){
         
         Object data = subList[index];
         if (data is Map) {
           return OtherItem(data);
         }else{
           return FirstItem(data);
         }
       },

     ),
     );
   }
 }
 class FirstItem extends StatelessWidget {

  final List<Map> data;

  FirstItem(this.data);

  List<Widget> _getChildren() {
    return data.map((dataMap) {
      return Expanded(
        flex: 1,
        child: Column(
          mainAxisAlignment: MainAxisAlignment.start,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Container(
              padding: EdgeInsets.only(left: 16.0,bottom: 16.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text(dataMap['name'],style: TextStyle(color:Color(0xff808080),fontSize: 10.0,),),
                  SizedBox(height: 2),
                  Text(dataMap['content'],style: TextStyle(color:Color(0xff404040),fontSize: 14.0,fontWeight: FontWeight.bold),),
                ],
              ),
            ),
          ],
        ),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.start,
      children: _getChildren(),
    );
  }
}

class OtherItem extends StatelessWidget {

  final Map data;

  OtherItem(this.data);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisAlignment: MainAxisAlignment.start,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        Container(
           padding: EdgeInsets.only(left: 16.0,bottom: 16.0),
           child: Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Text(data['name'],style: TextStyle(color:Color(0xff808080),fontSize: 10.0),),
                SizedBox(height: 2.0,),
                Text(data['content'],style: TextStyle(color:Color(0xff404040),fontSize: 14.0,fontWeight: FontWeight.bold),),
             ],
           ),
        ),
      ],
    );
  }
}
